//url 地址验证
function isExal(url) {
    var reg = /^(((ht|f)tps?):\/\/)?[\w-]+(\.[\w-]+)+([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?$/;
    if (url.test(reg)) {
        return true;
    } else {
        return false;
    }
}


//日期格式化处理

function format(str) {
    var date = new Date();
    // var Y = date.getFullYear();
    // var M = date.getMonth();
    // M = M < 10 ? "0" + M : M;
    // var D = date.getDate();
    // D = D < 10 ? "0" + D : D;
    // var h = date.getHours();
    // h = h < 10 ? "0" + h : h;
    // var m = date.getMinutes();
    // m = m < 10 ? "0" + m : m;
    // var s = date.getSeconds();
    // s = s < 10 ? "0" + s : s;
    // var obj = {
    //     Y: date.getFullYear(),
    //     M: date.getMonth() < 10 ? "0" + date.getMonth() : date.getMonth(),
    //     D: date.getDate() < 10 ? "0" + date.getDate() : date.getDate(),
    //     h: date.getHours() < 10 ? "0" + date.getHours() : date.getHours(),
    //     m: date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes(),
    //     s: date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds()
    // }

    var objx = {
        "Y+": date.getFullYear(),
        "M+": date.getMonth(),
        "D+": date.getDate(),
        "h+": date.getHours(),
        "m+": date.getMinutes(),
        "s+": date.getSeconds()

    }
    var res = 'YYYY-MM-DD hh:mm:ss';
    for (let x in objx) {
        objx[x] = objx[x] < 10 ? "0" + objx[x] : "" + objx[x];
        var reg = new RegExp(x);
        // console.log(res);
        res = res.replace(reg, objx[x]);
        console.log(res);
    }
    console.log(res);

    return res;

}
format("");
// function one(num) {
//     num = num < 10 ? "0" + num : '' + num;
//     return num;
// }
//时间戳
//2020-12-03 11:03:23
//2020\12\01\13\13\31

//数组合并 数组去重/^((ht|f)tps?:\/\/)?[\w-]+(\.[\w-]+)+:\d{1,5}\/?$/